<?php
namespace App\Http\Controllers\H5;

use App\Service\H5\TaskService;
use Illuminate\Http\Request;

class TaskController extends BaseController
{
    //列表
    public function index(Request $request)
    {
        $pas['depart_id'] = $request->post('depart_id', 0);
        $res = TaskService::index($pas);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson(0, '', $res['data']);
    }

    //详情
    public function getOne(Request $request)
    {
        $id = $request->post('id', 0);
        $res = TaskService::getOne($id);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson(0, '', $res['data']);
    }

    //修改
    public function modify(Request $request)
    {
        $id = $request->post('id', 0);
        $pas['role_id'] = $request->post('role_id', 0);
        $pas['depart_id'] = $request->post('depart_id', 0);
        $pas['staff_id'] = $request->post('staff_id', 0);
        $pas['title'] = $request->post('title', '');
        $pas['detail'] = $request->post('detail', '');
        $pas['in_day'] = $request->post('in_day', '');
        if ($id) {
            $res = TaskService::modify($id, $pas);
        } else {
            $res = TaskService::add($pas);
        }
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }
//
//    //删除
//    public function del(Request $request)
//    {
//        $id = $request->post('id', 0);
//        $res = ItemService::del($id);
//        if ($res['code'] < 0) {
//            return self::toJson(-2, $res['msg']);
//        }
//        return self::toJson();
//    }
}